package com.senven.branch.controller.api;

import com.senven.branch.service.BranchService;
import com.senven.common.entity.Branch;
import com.senven.common.vo.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author wt
 * @Date 2022/8/29 17:56
 * @PackageName:com.senven.branch
 * @ClassName: controller
 * @Description: TODO
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/branch")
public class ApiBranchController {
    @Autowired
    private BranchService branchService;

    @GetMapping("/findAll")
    public List<Branch> findAll(){
        List<Branch> result = branchService.findAl();
        return result;
    }

    @PostMapping("/findById/{id}")
    public CommonResult findById(@PathVariable Integer id){
        CommonResult result = branchService.findById(id);
        return result;
    }

    @PostMapping("/findByI")
    public Branch findByI(Integer branchid){
        Branch result = branchService.findByI(branchid);
        return result;
    }

    @PostMapping("/insertBranch")
    public int insertBranch(@RequestBody Branch branch){
        System.out.println(branch);
        int i = branchService.insertBranch(branch);
        return i;
    }
}
